public class Work04 {
    public static void main(String[] args) {
        //2022起始日期
        int n = 20220101;

        //顺子数组
        String [] str = {"012","123","234","345","456","567","678","789"};

        int count = 0;
        while (n <= 20221231){
            //如果日期合法
            if (judge(n)){
                //如果存在顺子
                if (func(n+"",str)){
                    count++;
                }
            }
            n++;
        }
        System.out.println(count);
    }

    //判断日期是否合法
    public static boolean judge(int n){
        //2022年是平年，2月只有28天
        int[] arr = {31,28,31,30,31,30,31,31,30,31,30,31};

        int month = n % 10000 / 100;
        int day = n % 100;

        if(day <= arr[month-1] && day > 0 && month <= 12  && month >0) {
            return true;
        }
        return false;

    }

    //判断顺子
    public static boolean func(String s,String [] str){
        for( int i = 0 ; i < str.length ; i++ ){
            if (s.contains(str[i])){
                return true;
            }
        }
        return false;
    }

}
